#include<bits/stdc++.h>
#define int long long
#define base 131
#define N 3000006
using namespace std;

string s;
int Len;
int n, ans;
int a[N];
unordered_map<int, bool>f;
void dfs() {
	int sum = 0;
	for(int i = 1; i <= Len; i++) sum = sum * base + a[i];
	if(f[sum]) return;
	f[sum] = 1;
	ans++;
	int lstLen = Len;
	vector<int>p;
	for(int i = 1; i <= Len; i++) p.push_back(a[i]);
	for(int i = 1; i <= lstLen - 1; i++) {
		if(a[i] == 1 && a[i + 1] == 1 || a[i] == 2 && a[i + 1] == 2 || a[i] == 2 && a[i + 1] == 1) {
			Len -= 2;
			for(int j = i + 2; j <= lstLen; j++) a[j - 2] = a[j];
			dfs();
			Len += 2;
			for(int j = 1; j <= Len; j++) a[j] = p[j - 1];
		}
	}
}
signed main() {
	freopen("song.in", "r", stdin);
	freopen("song.out", "w", stdout);
	
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> s;
	n = s.length();
	s = " " + s;
	if(n <= 20) {
		Len = n;
		for(int i = 1; i <= n; i++) {
			if(s[i] == 'A') a[i] = 1;
			else a[i] = 2;
		}
		dfs();
		cout << ans;
	}
	else {
		for(int i = 1; i < n; i++) {
			if(s[i] == 'B') ans++;
		}
		cout << ans + 1;
	}

	return 0;
}
/*
ABABABBBAABABABBABAA
*/

